#pragma once

#include <QObject>
#include <qnetworkreply.h>
#include <qnetworkaccessmanager.h>
#include <qfile.h>

class KHttpManager  : public QObject
{
	Q_OBJECT

public:
	KHttpManager(QObject *parent);
	~KHttpManager();

	void httpGet(const QString& httpURL);
	void httpDownload(const QString& fileURL, const QString& savePath);
public slots:
	void onReadData();
	void onSaveData();
	void onHandleFinished();
	void downloadedFinished();
	void onHandleHttpError(QNetworkReply::NetworkError code);

signals:
	void readyReadHttp(QByteArray& httpData,QUrl replyURL);
	void readyDownloadHttp();
	void downloadProgress(qint64 byteRecieved, qint64 byteTotal);
private:
	QNetworkAccessManager* m_netManager;
	QByteArray m_httpData;
	QFile m_fileOutput;
};
